

//*****************************************************
// Pull Down Menü Startseite
//*****************************************************
$(document).ready(function(){
	$("#main_nav ul li").mouseover(function() {
		$(this).find("ul").slideDown(200, function() {});

		$(this).hover(function() {}, function(){
			$(this).find("ul").stop();
			$(this).find("ul").css("height","auto");
			$(this).find("ul").css("opacity","1");
			$(this).find("ul").fadeOut(200);
		});		
	});
});  	



//*****************************************************
// Direct Links (vertical Accordion auf der Startseite)
//*****************************************************
/*
$(document).ready(function(){
  $("#col1 ul").accordion({
      active: "#selected",
      header: ".head",
      autoHeight: false,
      //clearStyle: true,
      event: 'mouseover'
   }); 
   
}); 
       
 */             
//****************************************
// horizontal Accordion auf der Startseite         
//****************************************      
var DDSPEED = 10;
var DDTIMER = 15;

// main function to handle the mouse events //
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
      //c.style.opacity = 1;
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
  	//c.style.display = 'none';
    //c.style.height = '0px';
    h.timer = setTimeout(function(){c.style.height = '0px';},20);
  }
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  if(c.style.height=="4px") c.style.height="0px"; //changed by PeterM
  c.style.opacity = currh / c.maxh; //changed by PeterM
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}


// SeViR Simple Horizontal Accordion @2007
// http://letmehaveblog.blogspot.com
jQuery.fn.extend({
  haccordion: function(params){
    var jQ = jQuery;
    var params = jQ.extend({
      speed: 500,
      headerclass: "header",
      contentclass: "content",
      contentwidth: 845
    },params);
    return this.each(function(){
    
    	this.opened = jQ("."+params.contentclass,this).filter(".visible").prev();
    
      jQ("."+params.headerclass,this).click(function(){
      	
        var p = jQ(this).parent()[0];
        if (p.opened != "undefined"){
          jQ(p.opened).next("div."+params.contentclass).animate({
            width: "0px"
          },params.speed);
        }
        p.opened = this;
        jQ(this).next("div."+params.contentclass).animate({
          width: params.contentwidth + "px"
        }, params.speed);
      });
    });
  }
});

function SetSel(id) {
	/*if (lang == "DE") path = "acc"; else path = "acc_en";*/
	for (i=1; i<=3; i++) {
		document.images["img_"+i].src = "images/h"+i+"_no.png";
	}
	document.images["img_"+id].src = "images/h"+id+"_a.png";
}


function getPlayer(gid) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[gid];
	} else {
		return document[gid];
	}
};

function playerReady(obj) {
	var id = obj['id'];
	var version = obj['version'];
	var client = obj['client'];
	//alert('player '+id+' has been instantiated');
	player = getPlayer('ply');
	//alert(player.getConfig().state);
	player.addModelListener("STATE","checkVideoState");
};

function getPlayer(gid) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[gid];
	} else {
		return document[gid];
	}
};

function checkVideoState(obj) {
	//if (obj.newstate=="COMPLETED") videoEnd();
}


/* ----------------------------------------*/
/* Accordion New mit On mouseover (Reiter) */ 
/* ----------------------------------------*/

var slideMenu=function(){
	var sp,st,t,m,sa,l,w,sw,ot;
	return{
		build:function(sm,sw,mt,s,sl,h){
			sp=s; st=sw; t=mt;
			m=document.getElementById(sm);
			sa=m.getElementsByTagName('li');
			l=sa.length; w=m.offsetWidth; sw=w/l;
			ot=Math.floor((w-st)/(l-1)); var i=0;
			for(i;i<l;i++){s=sa[i]; s.style.width=sw+'px'; this.timer(s)}
			if(sl!=null){m.timer=setInterval(function(){slideMenu.slide(sa[sl-1])},t)}
		},
		timer:function(s){s.onmouseover=function(){clearInterval(m.timer);m.timer=setInterval(function(){slideMenu.slide(s)},t)}},
		slide:function(s){
			var cw=parseInt(s.style.width,'10');
			if(cw<st){
				var owt=0; var i=0;
				for(i;i<l;i++){
					if(sa[i]!=s){
						var o,ow; var oi=0; o=sa[i]; ow=parseInt(o.style.width,'10');
						if(ow>ot){oi=Math.floor((ow-ot)/sp); oi=(oi>0)?oi:1; o.style.width=(ow-oi)+'px'}
						owt=owt+(ow-oi)}}
				s.style.width=(w-owt)+'px';
			}else{clearInterval(m.timer)}
		}
	};
}();

$(document).ready(function(){
	if ( $("#sm").length > 0 ) {
		slideMenu.build('sm',845,11,11,1);
	}
	
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
});

